<%@page language="java" contentType="text/html; charset=utf-8"%>
<%@include file="/tagDeclare.jsp"%>
<%@include file="/headDeclare.jsp"%>
<html>
<head>
	<style type="text/css"> 
	  fieldset,legend,form,table,tr,td,textarea{margin:0;padding:0}
	  form label {font-weight:bold;}
	  table{margin:10px 10px;};
	  td{line-height: 40px;}
	  input[type="text"]{width:250px;}
	  input[type="password"]{width:250px;}
	  input[type="textarea"]{width:250px;}
	</style>

	<script type="text/javascript">
	var dialog = frameElement.dialog;
	  $(document).ready(function(){
		     $('#oldPwd').focus();
		     $.ajaxSetup ({ cache:false,async: false });
		     //异步提交表单
		     var options = {dataType: 'json', beforeSubmit: beforeSubmit, success: process};
		     $("#userForm").submit(function(){
		         $(this).ajaxSubmit(options);
		          return false;
		     });   
	  });
	 
	   //提交前验证
	   function beforeSubmit() {
		     return true;
	   }
	
	   function process(responseJson) {
		   if(responseJson.code == 0) {
		         $('#error_label').text("错误信息：" + responseJson.message);
		         $("#p_error").show();
		         return;
		     }
		     else
		     {   
		    	 $.ligerDialog.success(responseJson.message,function(yes){
		    		location.href = "<%=basePath%>logout.do";
		    	 });
		     }
	   } 
	</script>
</head>
<body>
  <div>
      <form id="userForm" method="post" action="updatePwd.do">
      	<p id = "p_error" style = "margin:10px 10px;">
      	    <label id="error_label" style="color:red;"></label>
      	</p>
        <table cellspacing="10" cellpadding="0" >
		    <tr>
			    <td><label for="town">用户名：</label></td>
				<td>
				   <input type="text" name="username" id="username" value="${user.username }" readonly="readonly" />
				</td>
			</tr>
			<tr>
			    <td><label for="password">旧密码：</label></td>
				<td>
				   <input type="password" name="oldPwd" id="oldPwd"  />
				</td>
			</tr>
			<tr>
			    <td><label for="password2">新密码：</label></td>
				<td>
				   <input type="password" name="newPwd"  />
				</td>
			</tr>
        </table>
      </form>
    </div>
</body>
</html>